package com.ccx.coachsite.weibo.auth2.vo;


import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

import android.graphics.Bitmap;
import android.text.TextUtils;

import com.ccx.coachsite.weibo.json.JSONObject;


/**
 * 一条微博数据的封装对象
 * @author zhuchenghua
 */
public class Status implements Serializable{

	private static final long serialVersionUID = -6028111965755932546L;
	private static final String TAG="Status";
	
	/**数据库存储的微博ID*/
	private long id;
	
	/**登陆用户的数据库表ID*/
	private long userDbId;
	
	/**微博ID*/
	private String weiboId;
	
	/**创建时间*/
	private String createdAt;
	
	/**	微博信息内容 */
	private String text;
	
	/**微博来源 */
	private String source;
	
	/**	是否已收藏 */
	private boolean favorited;
	
	/**	是否被截断 */
	private boolean truncated;
	
	/**	回复ID */
	private String inReplyToStatusId;
	
	/**回复人UID*/
	private String inReplyToUserId;
	
	/**	回复人昵称 */
	private String inReplyToScreenName;
	
	/**微博MID */
	private long mid;
	
	/**	中等尺寸图片地址 */
	private long repostsCount;
	
	/**原始图片地址 */
	private long commentsCount;
	
	/**缩略图片地址 */
	private String bmiddlePic ;
	
	/**	转发数 */
	private String originalPic ;
	
	/**评论数 */
	private String thumbnailPic;
	
	/**是否已被删除*/
	private boolean isDeleted;
	
	/**微博作者的用户信息*/
	private User user;
	
	/**转发的微博*/
	private Status retweenStatus;
	
	/**微博的JSON形式数据*/
	private transient JSONObject statusJsonObj;
	
	/**
     * 微博发布的图片，不作序列化
     */
    private transient Bitmap postImage;
    
    /**
     * 是否被选中，是为列表项选中事件服务
     */
    private boolean isSelected=false;
    
	public Status(){}
	
	public Status(String jsonString)
	{
		try {
			JSONObject jsonObj=new JSONObject(jsonString);
			constructStatus(jsonObj);
		} catch (Exception e) {
		}
	}
	
	public Status(JSONObject jsonObj)
	{
		constructStatus(jsonObj);
	}
	
	private void constructStatus(JSONObject jsonObj)
	{
		if(jsonObj==null)
			return;
		this.statusJsonObj=jsonObj;
		try {
			String UTD_CreateAt=jsonObj.getString("created_at");
			if(!TextUtils.isEmpty(UTD_CreateAt))
			{
				try {
					Date date=new Date(UTD_CreateAt);
					SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm");
					this.createdAt=sdf.format(date);
				} catch (Exception e) {
					this.createdAt=UTD_CreateAt;
				}
				
			}
			
			this.weiboId=jsonObj.getString("idstr");
			this.text=jsonObj.getString("text");
			this.source=jsonObj.getString("source");
			this.favorited=jsonObj.getBoolean("favorited");
			this.truncated=jsonObj.getBoolean("truncated");
			this.inReplyToStatusId=jsonObj.getString("in_reply_to_status_id");
			this.inReplyToUserId=jsonObj.getString("in_reply_to_user_id");
			this.inReplyToScreenName=jsonObj.getString("in_reply_to_screen_name");
			this.mid=jsonObj.getLong("mid");
			this.bmiddlePic=jsonObj.getString("bmiddle_pic");
			this.originalPic=jsonObj.getString("original_pic");
			this.thumbnailPic=jsonObj.getString("thumbnail_pic");
			this.repostsCount=jsonObj.getLong("reposts_count");
			this.commentsCount=jsonObj.getLong("comments_count");
			String isDel=jsonObj.getString("deleted");
			if(isDel!=null && isDel.equals("1"))
				this.isDeleted=true;
			else
				this.isDeleted=false;
			
			//发布人
			this.user=new User(jsonObj.getJSONObject("user"));
			
			//转发微博
			if(jsonObj.getJSONObject("retweeted_status")!=null)
				this.retweenStatus=new Status(jsonObj.getJSONObject("retweeted_status"));
		} catch (Exception e) {
		}
		
		
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public long getUserDbId() {
		return userDbId;
	}

	public void setUserDbId(long userDbId) {
		this.userDbId = userDbId;
	}

	public String getWeiboId() {
		return weiboId;
	}

	public void setWeiboId(String sId) {
		this.weiboId = sId;
	}

	public String getCreatedAt() {
		return createdAt;
	}

	public void setCreatedAt(String createdAt) {
		this.createdAt = createdAt;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public String getSource() {
		return source;
	}

	public void setSource(String source) {
		this.source = source;
	}

	public boolean isFavorited() {
		return favorited;
	}

	public void setFavorited(boolean favorited) {
		this.favorited = favorited;
	}

	public boolean isTruncated() {
		return truncated;
	}

	public void setTruncated(boolean truncated) {
		this.truncated = truncated;
	}

	public String getInReplyToStatusId() {
		return inReplyToStatusId;
	}

	public void setInReplyToStatusId(String inReplyToStatusId) {
		this.inReplyToStatusId = inReplyToStatusId;
	}

	public String getInReplyToUserId() {
		return inReplyToUserId;
	}

	public void setInReplyToUserId(String inReplyToUserId) {
		this.inReplyToUserId = inReplyToUserId;
	}

	public String getInReplyToScreenName() {
		return inReplyToScreenName;
	}

	public void setInReplyToScreenName(String inReplyToScreenName) {
		this.inReplyToScreenName = inReplyToScreenName;
	}

	public long getMid() {
		return mid;
	}

	public void setMid(long mid) {
		this.mid = mid;
	}

	public long getRepostsCount() {
		return repostsCount;
	}

	public void setRepostsCount(long repostsCount) {
		this.repostsCount = repostsCount;
	}

	public long getCommentsCount() {
		return commentsCount;
	}

	public void setCommentsCount(long commentsCount) {
		this.commentsCount = commentsCount;
	}

	public String getBmiddlePic() {
		return bmiddlePic;
	}

	public void setBmiddlePic(String bmiddlePic) {
		this.bmiddlePic = bmiddlePic;
	}

	public String getOriginalPic() {
		return originalPic;
	}

	public void setOriginalPic(String originalPic) {
		this.originalPic = originalPic;
	}

	public String getThumbnailPic() {
		return thumbnailPic;
	}

	public void setThumbnailPic(String thumbnailPic) {
		this.thumbnailPic = thumbnailPic;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Status getRetweenStatus() {
		return retweenStatus;
	}

	public void setRetweenStatus(Status retweenStatus) {
		this.retweenStatus = retweenStatus;
	}

	public JSONObject getStatusJsonObj() {
		return statusJsonObj;
	}

	public void setStatusJsonObj(JSONObject statusJsonObj) {
		this.statusJsonObj = statusJsonObj;
	}

	public Bitmap getPostImage() {
		return postImage;
	}

	public void setPostImage(Bitmap postImage) {
		this.postImage = postImage;
	}

	public boolean isSelected() {
		return isSelected;
	}

	public void setSelected(boolean isSelected) {
		this.isSelected = isSelected;
	}

	public boolean isDeleted() {
		return isDeleted;
	}

	public void setDeleted(boolean isDeleted) {
		this.isDeleted = isDeleted;
	}
	
	
}
































